package com.tianji.remark.task;

import com.tianji.remark.service.ILikedRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
@RequiredArgsConstructor
public class LikedTimesCheckTask {

    private static final List<String> BIZ_TYPES = List.of("QA", "NOTE");// 业务类型
    private static final int MAX_BIZ_SIZE = 30;// 业务个数

    private final ILikedRecordService recordService;

    /**
    * @Description 定时读取点赞次数，并发送消息
    * @Author 老李头儿
    * @Date 2025年04月01 10:54:02
    * @param
    * @Return void
    **/

    @Scheduled(fixedDelay = 20000)
    public void checkLikedTimes(){
        log.info("开始读取点赞次数.....");
        for (String bizType : BIZ_TYPES) {
            recordService.readLikedTimesAndSendMessage(bizType, MAX_BIZ_SIZE);
        }
    }
}